var Shebei = new Vue({
    el : "#Shebeilist",
    data :{
        xiangmuId : $("#xiangmuId").val(),
        xiangmu : {},
        shebei :{},
        list : [],
        show : false,					// 显示列表是否有数据

    },

    created : function() {
        var _this = this;
        xiangmuId=_this.xiangmuId;
        _this.bindList();
        _this.bindXiangmu();

    },
    methods : {
        toback : function() {
            window.history.go(-1);
        },
        bindXiangmu:function (){
            var _this = this;
            layer.open({type:3});
            $.post('/xiangmu/find_one', {
                xianmguid : _this.xiangmuId,
                rdm : Math.random()
            },function(ppData) {
                layer.closeAll("loading");
                if(ppData != null){
                    if(ppData.result == "1"){
                        var data = ppData.resultContent;
                        _this.xiangmu = data;
                    }else{
                        layer.alert(ppData.message);
                    }
                }
            },"json");
        },
        toDelete:function (){
            var _this = this;
            layer.confirm("确定删除该项目的引进材料吗？",{
                btn : ['是','否']
            },function(){
                layer.open({type:3});
                $.post("/shebei/delete", {
                    xiangmuid : _this.xiangmuId,
                    random : Math.random()
                }, function(ppData) {
                    if (ppData != null) {
                        layer.closeAll("loading");
                        if(ppData.result != "1"){
                            layer.alert(ppData.message);
                        }else{
                            layer.open({
                                time:1000,
                                btn:[],
                                content:"删除成功!",
                            });
                            _this.bindList();
                            _this.bindXiangmu();
                        }
                    }
                },"json");
            })
        },

        bindList:function (){
            var _this = this;
            layer.open({type:3});
            $.post("/shebei/findlist",{
                xiangmuid : _this.xiangmuId,
                rdm : Math.random()
            },function(ppData){
                layer.closeAll("loading");
                if (ppData != null){
                    if(ppData.result == "1"){
                        var data=ppData.resultContent;
                        _this.show = true;
                        _this.list = data;
                    }else {
                        _this.show = false;
                    }
                }
            },"json");
        },

    }
});
